package com.fancy.util;

import entity.*;

import java.lang.reflect.Field;

public class SQLGenerator {

    private static StringBuilder sb = new StringBuilder();

    public static String insertGenerator(Class<?> clazz ){
        if(clazz == null)
            return null;

        Field[] fields = clazz.getDeclaredFields();
        int j = fields.length;
        sb.append("(");
        for (int i = 0 ; i < fields.length ; i++){
            fields[i].setAccessible(true);
            sb.append("#{" + fields[i].getName() + "},");
        }

        if ( j != 0){
            sb.deleteCharAt(sb.length()-1);
        }
        sb.append(")");
        return sb.toString();
    }

    public static void main(String[] args){
        String s = SQLGenerator.insertGenerator(PersonChatMessage.class);
        System.out.print(s);
    }
}